package net.fdukedom.epicurus.service.interaction;

import org.jdom.Element;

/**
 * 
 * @author Alexander Kirakozov
 * 
 */
public class ProfileXMLWrapper extends XMLWrapper {
	/**
	 * Sex element
	 */
	static final public String PROFILE = "Profile";

	/**
	 * Sex element
	 */
	static final protected String SEX = "Sex";

	/**
	 * Nick-name element
	 */
	static final protected String NICKNAME = "NickName";

	/**
	 * Constructor
	 * @param element
	 */
	public ProfileXMLWrapper(Element element) {
		super(element);
	}

	/**
	 * Constructor
	 * 
	 * @param nickName
	 * @param sex
	 */
	public ProfileXMLWrapper(String nickName, Short sex) {
		element = new Element(PROFILE);

		Element elem = new Element(NICKNAME);
		elem.setText(nickName);
		element.addContent(elem);

		elem = new Element(SEX);
		elem.setText(new Short(sex).toString());
		element.addContent(elem);
	}

	/**
	 * Get user sex
	 * 
	 * @return sex
	 */
	public short getSex() {
		return Short.parseShort(element.getChildText(SEX));
	}

	/**
	 * Get use nick name
	 * 
	 * @return nick name
	 */
	public String getNickName() {
		return element.getChildText(NICKNAME);
	}
}
